package com.acmen.easyapi.service;

import com.acmen.easyapi.dto.PressureTestCmd;
import com.acmen.easyapi.executor.PressureTestExe;
import com.acmen.easyapi.model.PressureTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
 * @author acmen
 */
@Service
public class PressureTestService {
    @Autowired
    private PressureTestExe pressureTestExe;

    public ModelAndView index(HttpServletRequest request, ModelMap model) {
        return pressureTestExe.index(request,model);
    }
    public void progress(HttpServletRequest request, HttpServletResponse response) throws IOException {
        pressureTestExe.progress(request,response);
    }

    public void exec(PressureTestCmd pressureTestCmd, HttpServletResponse response) throws InterruptedException, IOException {
        pressureTestExe.exec(pressureTestCmd,response);
    }

    public List<PressureTest> selectListByAppName(String appName) {
        return pressureTestExe.selectListByAppName(appName);
    }

    @Transactional(rollbackFor = Exception.class)
    public boolean delete(String id) {
        return pressureTestExe.delete(id);
    }

    public PressureTest getById(String id) {
        return pressureTestExe.getById(id);
    }
}
